import { observable, action } from 'mobx';
import { WeaTools } from 'ecCom';
import moment from 'moment';
import * as knowledgeMap from '../../apis/knowledgeMap/knowledgeMap';

export default class KnowledgeListStore {
    constructor(props) {

    }

    @observable cyearmonth = new moment().format('YYYY-MM');
    @observable loading = false;
    @observable name = '';// 知识地图名称
    @observable createrId = '';// 创建人
    @observable createrArray = '';// 创建人
    @observable slidevisible = false;//

    @observable hasRight = false;
    @observable hasaddmenu = false;
    @observable dataSource = [];
    @observable itotal = 0;
    @observable pageNum = 0;
    @observable totalPage = 0;

    /**
     * 获取知识地图列表信息
     */
    @action
    getKnowledgeList(params) {
        this.loading = true;
        knowledgeMap.getList(params).then((data) => {
            if (data.status == 1) {
                this.dataSource = data.datas;
                this.itotal = data.itotal;
                this.pageNum = data.pageNumber;
                this.totalPage = data.totalPage;
                this.hasRight = data.hasRight;
                this.hasaddmenu = data.hasaddmenu;
            }
            if (params && params.doback) {
                params.doback(data.hasRight, data.hasaddmenu);
            }
            this.loading = false;
        });
    }

     /**
     * 删除知识知识地图
     */
    @action
    operateKnowledge(params) {
        knowledgeMap.operateKnowledge(params).then((data) => {
           if (params.doback) {
              params.doback(data.status);
           }
        });
    }
}
